package mornd.test1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * @author: mornd
 * @dateTime: 2023/5/4 - 14:00
 */

@Component
public class Component1 {

    @Autowired
    private ApplicationEventPublisher context;

    public void register() {
        System.out.println("正在注册");
        // 事件发布，这里由 component2 监听
        context.publishEvent(new UserRegisterEvent(this));
    }
}
